/**
 * Scalog - Scalog is a logging framework for the Scala programming language.
 * Copyright (C) 2009  Laurent Grangier
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.scalog

import net.scalog.config._;
import net.scalog.appender.Appender;

/**
 * A logger. 
 * 
 * @author Laurent Grangier
 */
class Logger(val name : String) {
  
  /** Tests if the logger is enabled. */
  def isEnabled(level : Level) : Boolean = ConfigurationManager.isEnabled(this, level)
  
  def log(message : Any, throwable : Throwable, level : Level) : Unit = {
    val logMessage = new LogMessage(this, level, message, throwable, System.currentTimeMillis);
    // doAppend the logMessage to all the appenders
    ConfigurationManager.getAppenders(this).foreach(_.doAppend(logMessage));
  }
  
}

